// pages/my/my.js
Page({

  data: {
    wrongQuestionIds: [],
    user_id: ''
  },


  onLoad(options) {
    this.ymjz();
  },
  onShow() {
    this.ymjz();
  },
  ymjz() {
    let wrongQuestionIds = wx.getStorageSync('wrongQuestionIds') || [];
    let user_id = wx.getStorageSync('user_id') || '';
    this.setData({
      wrongQuestionIds: wrongQuestionIds,
      user_id: user_id
    })
    console.log(this.data.wrongQuestionIds)
  },

  tc() {
    wx.showToast({
      title: '已退出',
      icon: 'success'
    })
    wx.navigateTo({
      url: '/pages/login/login',
    })
  },
  ctcz() {
    const wrongQuestionIds=this.data.wrongQuestionIds.length
    wx.showModal({
      title: '提示',
      content: '是否开始重做',
      success: function (res) {
        if (res.confirm) {
          if (wrongQuestionIds === 0) {
            wx.showToast({
              title: '没有错题',
              icon: 'error'
            })
          }else{
           wx.navigateTo({
             url: '/pages/ct/ct',
           })
          }
          console.log('用户点击确定');
        } else if (res.cancel) {
          console.log('用户点击取消');
        }
      }
    });

  }
})